<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateActivityCitiesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('activity_cities', function (Blueprint $table) {
            $table->bigIncrements('id')->unsigned();

            $table->integer('city_id')->unsigned()->comment('城市id');
            $table->foreign('city_id')->references('id')->on('cities');

            $table->integer('activity_id')->unsigned()->comment('活动id');
            $table->foreign('activity_id')->references('id')->on('activities');

            $table->tinyInteger('sort_order')->unsigned()->comment('活动城市排序号');

            $table->string('description', 8000)->nullable()->comment('活动详情：富文本，默认同主活动的description一致');

            $table->string('contact', 100)->nullable()->comment('本地咨询电话');
            $table->string('contact_people', 100)->nullable()->comment('本地联系人：文本，可输入多个人员，方便志愿者了解详细情况');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('activity_cities', function ($table) {
            $table->dropForeign(['activity_id']);
            $table->dropForeign(['city_id']);
        });
        Schema::dropIfExists('activity_cities');
    }
}
